Skip to content

Feat/added option to specify custom command description as array#1982

Open
Benni0 wants to merge 4 commits intosplunk:developfrom
Benni0:feat/add_cc_multiline_description
Open

Feat/added option to specify custom command description as array#1982
Benni0 wants to merge 4 commits intosplunk:developfrom
Benni0:feat/add_cc_multiline_description

Conversation

@Benni0
Copy link
Copy Markdown
Contributor

@Benni0 Benni0 commented Feb 8, 2026

PR Type

What kind of change does this PR introduce?

  • Feature
  • Bug Fix
  • Refactoring (no functional or API changes)
  • Documentation Update
  • Maintenance (dependency updates, CI, etc.)

Summary

Added the possibility to define the description of a custom command as an array of strings, to improve the readability of long comprehensive descriptions in json format. Each string will result in a single line of searchbnf.conf or within the description of the command python.

Changes

Modification of the json schema to allow a string array as description and modified the searchbnf.conf generator and the custom command python generator to format the description accordingly.

This is another update after #1977, #1979 and #1980.

User experience

It is now possible to split long descriptions in multiple lines, which improves the readability in globalConfig.json.

Checklist

If an item doesn't apply to your changes, leave it unchecked.

Review

  • self-review - I have performed a self-review of this change according to the development guidelines
  • Changes are documented. The documentation is understandable, examples work (more info)
  • PR title and description follows the contributing principles
  • meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket)

Tests

See the testing doc.

  • Unit - tests have been added/modified to cover the changes
  • Smoke - tests have been added/modified to cover the changes
  • UI - tests have been added/modified to cover the changes
  • coverage - I have checked the code coverage of my changes (see more)

Demo/meeting:

Reviewers are encouraged to request meetings or demos if any part of the change is unclear

Copy link
Copy Markdown
Contributor

@kkedziak-splunk kkedziak-splunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR adds support for specifying the command description as an array of strings (for better JSON readability) in addition to the existing single-string format. The multiline description is joined with \\\n for searchbnf.conf and with \n for Python docstrings.

Issues found:

  1. Join separator uses backslash-newline (create_searchbnf_conf.py): " \\\n".join(description) produces a backslash continuation in the .conf file. This works for searchbnf.conf, but it is worth verifying that Splunk's conf parser handles backslash line continuations correctly in description values. If not, consider joining with a single space instead.

  2. Python docstring join (create_custom_command_python.py): "\n ".join(description) joins with newline + 4 spaces indentation. This assumes the docstring context always has 4-space indentation. The template itself might have different indentation — verify this is consistent.

  3. description type changed in schema but not in all validators: The schema now uses oneOf: [string, array[string]] for description, which is good. But the _validate_custom_search_commands in global_config_validator.py still uses command.get("description") — this works for both types (truthy check) so it's fine. Just noting that the error message on the validation failure path still says "One of the attributes among description, usage, syntax" from the stacked PRs.

  4. No validation for empty strings in array: The schema allows {"type": "array", "items": {"type": "string"}} without minLength on items or minItems on the array. An empty array [] or array with empty strings [""] would pass schema validation but produce empty/broken descriptions.

  5. Doc table type column: The type is shown as string or array[string] — consider using string \| array[string] or similar markdown-friendly formatting for clarity in the rendered table.

Overall a clean feature addition with good test coverage (both conf file output and Python file output).

syntax_lines[-1] += f" {part}"
else:
syntax_lines.append(part)
syntax = " \\\n".join(syntax_lines)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The join separator " \\\n" produces backslash line continuations in the .conf file. Worth verifying Splunk's conf parser handles backslash continuations correctly in description values of searchbnf.conf. If not, joining with a single space might be safer.


description = command.get("description")
if description and isinstance(description, list):
description = "\n ".join(description)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The join separator "\n " (newline + 4 spaces) assumes the docstring context always has 4-space indentation. Verify this is consistent with the template's indentation.

"oneOf": [
{
"type": "string"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oneOf allows an array with no minItems and string items with no minLength. An empty array [] or [""] would pass validation but produce an empty or near-empty description. Consider adding minItems: 1 and/or minLength: 1 on the string items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants